<?php
//ini_set("display_errors",1);
my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('alamat' , false);
my_component_load('pr_direct_calc' , false);
my_component_load('kekaryawanan');
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;

$modulname = "Personalia _BN_ Data Karyawan _BN_ Kekaryawanan";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "edit" :
			if(! is_admin())fatal_error('Akses ditolak!!!');
			$validate = form_submit_validate($id);
			if($validate){
				$pagename = "Edit Data Kekaryawanan";
				$content = message_multi_error($validate );
				$content .= form_edit($id);
			}else{
				$kid = form_submit_kekaryawanan($id);
				my_direct('index.php?com=kekaryawanan&task=edit&id='.$id);
			}
			break;
		case   "edit_jabatan_page" :
			$validatepost = validate_edit_jabatan($kid, $id );
			if ($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_edit_jabatan($kid, $id );
				generate_my_web($content,"","plain.php");
				exit;
			}else{
				submit_edit_jabatan($kid, $id );
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			 }
			break;
		case   "set_finger_page" :
			$validatepost = set_finger_validate($kid);
			if($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= set_finger_form($kid );
			}else{
				set_finger_submit( $kid );
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			break;
		case   "edit_pelatihan_page" :
			$validatepost = validate_edit_pelatihan($kid, $id );
			if ($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_edit_pelatihan($kid, $id );
				generate_my_web($content,"","plain.php");
				exit;
			}else{
				submit_edit_pelatihan($kid, $id );
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			 }
			break;			
		case   "edit_kompetensi_page" :
			$validatepost = validate_edit_kompetensi($kid, $id );
			if ($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_edit_kompetensi($kid, $id );
				generate_my_web($content,"","plain.php");
				exit;
			}else{
				submit_edit_kompetensi($kid, $id );
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			 }
			break;			
	}

else: 	
	if($task == "edit"){
		if(! is_admin())fatal_error('Akses ditolak!!!');
		$pagename =$modulname." _BN_ Ubah Data";
		$content = form_edit($id);
	}elseif($task == 'set_finger'){	
		$title= ($id > '0' ) ?  "Perubahan data" : "Tambah data";
		facebox_page('index.php?com='.$_GET['com'].'&task=set_finger_page&kid='.$kid  , $title , 210	); 
	}elseif($task == 'set_finger_page'){
		$content  =set_finger_form( $kid  );
		generate_my_web($content,"","plain.php");
		exit;						
	}elseif($task == 'excel_daftar_kekaryawan'){	
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=data_master_kekaryawan.xls");
		 echo export_to_excel();
		exit;
	}elseif($task == 'edit_jabatan'){	
		$title=   "Perubahan data finger" ;
		facebox_page('index.php?com=kekaryawanan&task=edit_jabatan_page&kid='.$kid.'&id='.$id  , $title , 310	); 
	}elseif($task == "edit_jabatan_page"){ 
		$_SESSION['tab_page'] = '#tab1';
		$content  = form_edit_jabatan($kid, $id );
		generate_my_web($content,"","plain.php");
		exit;						
	}elseif($task == 'edit_pelatihan'){	
		$title= ($id > '0' ) ?  "Perubahan data" : "Tambah data";
		facebox_page('index.php?com=kekaryawanan&task=edit_pelatihan_page&kid='.$kid.'&id='.$id  , $title , 310	); 
	}elseif($task == "edit_pelatihan_page"){ 
		$_SESSION['tab_page'] = '#tab2';
		$content  = form_edit_pelatihan($kid, $id );
		generate_my_web($content,"","plain.php");
		exit;						

	}elseif($task == 'edit_kompetensi'){	
		$title= ($id > '0' ) ?  "Perubahan data" : "Tambah data";
		facebox_page('index.php?com=kekaryawanan&task=edit_kompetensi_page&kid='.$kid.'&id='.$id  , $title , 310	); 
	}elseif($task == "edit_kompetensi_page"){ 
		$_SESSION['tab_page'] = '#tab5';
		$content  = form_edit_kompetensi($kid, $id );
		generate_my_web($content,"","plain.php");
		exit;						
		
	}elseif($task == "detail"){
		load_facebox_script();
		$pagename = $modulname." _BN_ Detail ";
		$content = form_detail($id);
	}else{
		$pagename = $modulname;
		load_facebox_script();
		$content = report_karyawan();
	}
endif; 
generate_my_web($content, $pagename  );
?>